﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebAppDemo.Classes;

namespace WebAppDemo.Performance
{
    public partial class PersonDemo : System.Web.UI.Page
    {
        PersonList pl=new PersonList();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                dlPersonList.DataSource =pl.GetList() ;
                dlPersonList.DataBind();
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var p = new Person(this.tbName.Text);
            pl.Add(p);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var name= this.txtId.Text;
            pl.Remove(name);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            dlPersonList.DataSource = pl.GetList();
            dlPersonList.DataBind();
        }

    }
}